import ReactDOM from "react-dom/client";
import { RouterProvider, createHashRouter } from "react-router-dom";

import "./global.css";
import Index from "./pages";
import DashboardConsole, {
  loader as consoleLoader,
} from "./pages/dashboard/console";
import DashboardWorkplace, {
  loader as workplaceLoader,
} from "./pages/dashboard/workplace";

// 创建路由器
const router = createHashRouter([
  {
    path: "/",
    element: <Index />,
    children: [
      {
        path: "/dashboard/console",
        loader: consoleLoader,
        element: <DashboardConsole />,
      },
      {
        path: "/dashboard/workplace",
        loader: workplaceLoader,
        element: <DashboardWorkplace />,
      },
    ],
  },
]);

ReactDOM.createRoot(document.getElementById("root")!).render(
  <RouterProvider router={router} />
);
